package ec.edu.udla.fichamedica.client;

import java.util.List;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.RootPanel;

import ec.edu.udla.fichamedica.client.editor.PersonDriver;
import ec.edu.udla.fichamedica.client.registromedico.Test;
import ec.edu.udla.fichamedica.client.ui.Home;
import ec.edu.udla.fichamedica.client.ui.PersonList;
import ec.edu.udla.fichamedica.domain.Person;
import ec.edu.udla.fichamedica.shared.LoginInfo;


/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class FichaMedicaWebApp implements EntryPoint {
	/**
	 * The message displayed to the user when the server cannot be reached or
	 * returns an error.
	 */
	private static final String SERVER_ERROR = "An error occurred while "
			+ "attempting to contact the server. Please check your network "
			+ "connection and try again.";

	/**
	 * Create a remote service proxy to talk to the server-side Greeting service.
	 */
	private final GreetingServiceAsync greetingService = GWT
			.create(GreetingService.class);
	
	private final LoginServiceAsync loginService = GWT.create(LoginService.class);
	
	public static PersonDriver driver = GWT.create(PersonDriver.class);

	List<Person> persons;
	private LoginInfo loginInfo = null;
	
	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {
		
//		loginService.login(GWT.getHostPageBaseURL(),
//				new AsyncCallback<LoginInfo>() {
//					public void onFailure(Throwable error) {
//						error.printStackTrace();
//						System.out.println("Failure");
//					}
//
//					public void onSuccess(LoginInfo result) {
//						loginInfo = result;
//						System.out.println("sucess");
//						Home home = new Home(loginInfo);
//						RootPanel.get().add(home);
//						if (loginInfo.isLoggedIn()) {
							
//				    	    signOutLink.setHref(loginInfo.getLogoutUrl());
//				    	    PersonList list = new PersonList();
						Principal principal = new Principal();
				    		RootPanel.get().add(principal);
//				    	    verticalMenuPanel.add(signOutLink);
//				    	    splitLayoutPanel.setVisible(true);
//						} else {
//							loadLogin();
//							splitLayoutPanel.setVisible(false);
//						}
//					}
//				});
		
//		Window.alert("Se agrego la tabla");
	
	}
	
	

}
